<script src="js_3d/jquery-ui-1.8.11.custom.min.js"></script>
<script src="js_3d/jquery.cookie.js"></script>
<script src="js_3d/jquery.dynatree.min.js"></script>
<link href="css/ui.dynatree.css" rel="stylesheet" type="text/css">
<style>
/* 浮动额度说明  Tooptip */
/*Tooltips*/


.tooltips {
	position: relative;
}
.tooltips:hover {
	background: none;
}
.tooltips span {
	display: none;
}
.tooltips:hover span {
	display: block;
	position: absolute;
	top: 21px;
	right: 115px;
	width: 180px;
	border: 1px solid black;
	background-color: #ccFFFF;
	padding: 3px;
	color: black;
}
.show_mbrs td {
	color: black;
}
</style>
<style type="text/css">
/* tree的设定 */


#tree {
	vertical-align: top;
	width: 97%;
}
ul.dynatree-container {
	overflow: visible;
}
span {
	color: #003366;
	font-size: 12px;
}
#leftSide {
	float: left;
	width: 100%;
}
/* 依层级 ,显示不同图示*/
span.acl255 span.dynatree-icon {
	background-position: 0 0;
	background-image: url("image/tree_acl255.jpg");
}
span.acl5 span.dynatree-icon {
	background-position: 0 0;
	background-image: url("image/tree_acl5.jpg");
}
span.acl4 span.dynatree-icon {
	background-position: 0 0;
	background-image: url("image/tree_acl4.jpg");
}
span.acl3 span.dynatree-icon {
	background-position: 0 0;
	background-image: url("image/tree_acl3.jpg");
}
span.acl2 span.dynatree-icon {
	background-position: 0 0;
	background-image: url("image/tree_acl2.jpg");
}
span.acl1 span.dynatree-icon {
	background-position: 0 0;
	background-image: url("image/tree_acl1.jpg");
}
form {
	margin: 0;
	padding: 0;
}
.enabled {
	background-color: #FF7573;
}
#leftTop {
	padding-bottom: 5px;
}
#divBtnOpen {
	padding-top: 0 !important;
}
#tree_body {
	margin-left: 3%;
}
</style>
<script>
/**
* 函数名称 : chg_url
* 功能说明 : 路径切换。
* 传入参数 : account,gametype,cmd
* 备注           : 依 account 参数做 Ajax ,返回`k_user`资料,
*           gametype 决定样板 ,0为六和,
*           cmd 决定模式(add,edit,list) ,预设list ,若为edit ,则edit&id='6'表示编辑id为6的会员帐号。
*/
function chg_url(account,cmd,login_acl){	
	if(cmd == 'list')
	{
		$("#Menu_List").show();
		$("#Menu_Tree").hide();	
		return true;
	}else{
	$("#Menu_List").hide();
	$("#Menu_Tree").show();
	}
	if(account != ''){
		
	   	   //采 Ajax的方式 ,依帐号 回传id值 
		   $.post("op.php?op=agent&fp=switch_data&para=1",{account:account},function(xml){				   
			   
		       	 $("result",xml).each(function(){
		       		 acl = $('acl',this).text(); //取得`acl`资料		
		       		 id = $('id',this).text(); //取得`id`资料	
		       		
		         	//依acl切换目录/档案
		       	     if(acl == 255){		       	    	 
		       			        //清单模式
					        	var op ='admin';
				       	        var fp ='subsidary'; 
				       	        window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&gametype={gametype}";				       	      
		       	            
		       		 }else if(acl == 5){	       			 
		       			 
		       			 //模式切换

		       	         if(cmd == 'edit'){ //1)编辑模式	
		       	        	    if(login_acl == 5){
		       	        		   var op ='subsidary';
			       	               var fp ='shareowner';
			       	               window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&prev_id="+id+"&gametype={gametype}";
		       	        	    }else{
		       	        	       var op ='admin';
       	                           var fp ='subsidary';
       	                           window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&cmd=edit&id="+id+"&gametype={gametype}"; 
		       	        	    }
		       	      
		       	         }else if(cmd == 'amount'){ //2)限额模式
		       	         
		       	        		if(login_acl == 5){
		       	        		   var op ='subsidary';
			       	               var fp ='shareowner';
			       	               window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&prev_id="+id+"&gametype={gametype}";
			       	        	}else{
			       	        	   var op ='agent';
     	                           var fp ='amount_3d';
     	                           window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&id="+id+"&gametype={gametype}"; 
			       	        	}  		 
		       	         
		       	         }else{ //3)清单模式
					        	var op ='subsidary';
			       	            var fp ='shareowner';
			       	            window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&prev_id="+id+"&gametype={gametype}"; 
			       	      }	     
		       		 }else if(acl == 4){			       			
		       		        
		       		     //模式切换
	       	             if(cmd == 'edit'){ //1)编辑模式
	       	            	 
	       	            	    if(login_acl == 4){
	       	            		   var op ='shareowner';
    		       	               var fp ='genagent';	    		       	            
    		       	               window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&prev_id="+id+"&gametype={gametype}";
	       	            	    }else{
	       	            	       var op ='subsidary';
    	                           var fp ='shareowner';	
    	                           window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&cmd=edit&id="+id+"&gametype={gametype}"; 
	       	            	    }
	       	             
		       		    }else if(cmd == 'amount'){ //2)限额模式
	       	        		 
	       	        		if(login_acl == 4){
	       	        		   var op ='shareowner';
		       	               var fp ='genagent';	    		       	            
		       	               window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&prev_id="+id+"&gametype={gametype}";
		       	        	}else{
		       	        	   var op ='agent';
	                           var fp ='amount_3d';
	                           window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&id="+id+"&gametype={gametype}"; 
		       	        	}  		 	       	             
	       	             
		       		 }else{ //3)清单模式	
                            	var op ='shareowner';
    		       	            var fp ='genagent';	    		       	            
    		       	            window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&prev_id="+id+"&gametype={gametype}";     		       	          
    		       	      }  		       			 
		       			 
		       		 }else if(acl == 3){	
		       			 
		       			 //模式切换
		       	         if(cmd == 'edit'){ //1)编辑模式
		       	        	 
		       	        	    if(login_acl == 3){
		       	        		   var op ='genagent';
 		       	                   var fp ='agent';
 		       	                   window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&prev_id="+id+"&gametype={gametype}";
		       	        	    }else{
		       	        	       var op ='shareowner';
	       	                       var fp ='genagent';	
	       	                       window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&cmd=edit&id="+id+"&gametype={gametype}"; 	       	        	 
		       	        	    }		       	     
		       	        }else if(cmd == 'amount'){ //2)限额模式
		       	         
	       	        	     if(login_acl == 3){
	       	        		     var op ='genagent';
	       	                     var fp ='agent';
	       	                     window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&prev_id="+id+"&gametype={gametype}";
	       	        	      }else{
		       	        	     var op ='agent';
	                             var fp ='amount_3d';
	                             window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&id="+id+"&gametype={gametype}"; 
		       	        	  }  		 
		       	    
                     }else{ //3)清单模式	
                        	   var op ='genagent';
  		       	               var fp ='agent';
  		       	               window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&prev_id="+id+"&gametype={gametype}";   	                    	
                     }		       			    
		       			  
		       		 }else if(acl == 2){	
		       			 
		       		     //模式切换
		       	         if(cmd == 'edit'){ //1)编辑模式       	        	  
	       	                   
		       	        	    if(login_acl == 2){ 
		       	        		   var op ='agent';
	  		       	               var fp ='member'; 
	  		       	               window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&prev_id="+id+"&gametype={gametype}"; 
		       			        }else{
		       	                   var op ='genagent';
		       	                   var fp ='agent'; 
		       	                   window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&cmd=edit&id="+id+"&gametype={gametype}"; 
		       	                }
		       		     
		       	         }else if(cmd == 'amount'){ //2)限额模式
		       	        		 
		       	        		if(login_acl == 2){
		       	        		   var op ='agent';
	  		       	               var fp ='member'; 
	  		       	               window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&prev_id="+id+"&gametype={gametype}"; 
		       			        }else{
			       	        	   var op ='agent';
		                           var fp ='amount_3d';
		                           window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&id="+id+"&gametype={gametype}"; 
			       	        	}  		 
		       	         
		       	          }else{ //3)清单模式	
                        	     var op ='agent';
  		       	                 var fp ='member'; 
  		       	                 window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&prev_id="+id+"&gametype={gametype}";                  
  		       	          }		    
		       	            
		       		 }else if(acl == 1){	

		       			 //模式切换
		       	         if(cmd == 'amount'){ //1)限额模式
		       	         
		       	        	  var op ='agent';
		                    var fp ='amount2_3d';
		                    window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&id="+id+"&gametype={gametype}"; 
			       	       } 
		       			 
		       	         else{ //2)编辑模式		    
		       	         
		       	            var op ='agent';
		       	            var fp ='member';    
		       	            window.parent.mainAccFrame.location.href="op.php?op="+op+"&fp="+fp+"&cmd=edit&id="+id+"&gametype={gametype}"; 		       	            
		       	         }
		       	   }	
		       		 
				});
		       	 
		   }); //结束post	    
     }

}


/**
* 函数名称 : show_tree
* 功能说明 : 依传入值 ,动态产生tree。
* 传入参数 : account,cmd,enabled,acl
* 备注           : 
*/
function show_tree(account,cmd,enabled){	
	
	$(function(){ 
	 
	//在 tree_body里面 ,建立tree
	$('#tree_body').append("<div id='tree'></div>");
	
	
	//采 Ajax的方式 ,依登入帐号 回传acl值 
	$.post("op.php?op=agent&fp=switch_data&para=1",{account:account},function(xml){
		
	$("result",xml).each(function(){
    //login_acl = $('acl',this).text(); //取得`acl`资料	    
    login_acl = $('#login_acl').val();
	
	
	//预设登入後 ,依acl切换路径
	chg_url(account,cmd,login_acl);	
	
	//tree主体	
	$("#tree").dynatree({	
		initAjax: {					
			 url: "op.php?op=agent&fp=switch_tree&account="+account+"&cmd="+cmd+"&enabled="+enabled,			                                                                             
             dataType:"json"		 
		},		
		onActivate: function(node) { 
			
            //依空白  ,拆解节点字串(参考 class.tree.php 的组成)    
            var acct = node.data.title.split(" ",1).toString();
                
                //依acl切换路径
	            chg_url(acct,cmd,login_acl);  
		},    
		minExpandLevel: 2, //展开层数
		persist: true, 
		//isLazy: true,
		strings: {
	        loading: "载入中…",
	        loadError: "载入失败!"
	    },	    
	    onClick: function(node){
	    	node.sortChildren(null, true);
		}	    
	 });
    
     });	    
	});	
 });

}


//页面载入主体
$(function(){		
	
	//动态产生tree的div
	$('#tree_body').append("<div id='tree'></div>");
	
	//'搜寻'钮的作用
	$('#srh_tree').click(function(){
		 if($("#cmd").val()=="list")
			$("#cmd").val("tree");
		 //清空并移除tree
		 $('#tree').empty().remove(); 
		 
		 //侦测[帐号]、[模式]、[状态	]栏位
		 var account = $('#account').val(); 
		 var cmd = $('select#cmd option:selected').val();		
		 var enabled = $('select#enabled option:selected').val();			 
		 		 
		//若输入栏位为空		       		 
		 if(account == ""){
			var account = $('#login_acct').val();
		 }		 
		 
		 //判断account的搜寻条件 ,是否为所属下线
		  $.post("op.php?op=agent&fp=switch_data&para=2",{account:account},function(xml){
		     
			   $("result",xml).each(function() {
				   serach = $('serach',this).text(); //取得serach资料			       		 
		       		 //判断输入栏位		       		 
		    		 if(serach == '0'){		    			
		    			 window.location.reload();
		    		 }else{					
		    			show_tree(account,cmd,enabled);
		    		 } 		       		 
				});
		 }); 
		 		 
		 
		 //查询帐号 ,采 Ajax的方式 ,回传'k_user'资料 
		 $.post("op.php?op=agent&fp=switch_data&para=1",{account:account},function(xml){
		       	 $("result",xml).each(function() {
		       		    acl = $('acl',this).text(); //取得`acl`资料      		 
		    			show_tree(account,cmd,enabled);
				});
		 });	 
		 
	});
	 
	 
	//侦测[状态]栏位输入值
	$('select#enabled').change(function(){
				 
		 //清空并移除tree
		 if($("#cmd").val()=="list")
			$("#cmd").val("tree");
		$('#tree').empty().remove();
				
		var account = $('#account').val(); 
		var cmd = $('select#cmd option:selected').val(); 		
		var enabled = $('select#enabled option:selected').val(); 	
				
		//若输入栏位为空		       		 
		 if(account == ""){
			var account = $('#login_acct').val();
		 }		 
		 
		//判断是否`acl`='255' ,若是 ,则无须比对可查询的下线 
		 if($('#login_acl').val() == '255'){			
			  show_tree(account,cmd,enabled);
		 }else{				 
			 //判断account的搜寻条件 ,是否为所属下线
			  $.post("op.php?op=agent&fp=switch_data&para=2",{account:account},function(xml){
			     
				   $("result",xml).each(function() {
					   serach = $('serach',this).text(); //取得serach资料			       		 
			       		 //判断输入栏位		       		 
			    		 if(serach == '0'){		    			
			    			 window.location.reload();
			    		 }else{					
			    			show_tree(account,cmd,enabled);
			    		 } 		       		 
					});
			 }); 			 
		 }		 
		 
	});
	
	
	//侦测[模式]栏位输入值
	$('select#cmd').change(function(){
				 
		 //清空并移除tree
		 $('#tree').empty().remove();
		
		var account = $('#account').val(); 
		var cmd = $('select#cmd option:selected').val(); 		
		var enabled = $('select#enabled option:selected').val(); 	
				
		 //若输入栏位为空		       		 
		 if(account == ""){
			var account = $('#login_acct').val();
		 }		 
		 		
		 //判断是否`acl`='255' ,若是 ,则无须比对可查询的下线 
		 if($('#login_acl').val() == '255'){			
			  show_tree(account,cmd,enabled);
		 }else{				  
			  //判断account的搜寻条件 ,是否为所属下线
			  $.post("op.php?op=agent&fp=switch_data&para=2",{account:account},function(xml){
			     
				   $("result",xml).each(function() {
					   serach = $('serach',this).text(); //取得serach资料			       		 
			       		 //判断输入栏位		       		 
			    		 if(serach == '0'){		    			
			    			 window.location.reload();
			    		 }else{					
			    			show_tree(account,cmd,enabled);
			    		 } 		       		 
					});
			 }); 
		 }	
		
	 });	
	
	
	 //tree全部展开
	 $("#btnExpandAll").click(function(){
	       $("#tree").dynatree("getRoot").visit(function(node){	    	   
	            node.expand(true); 
	            node.sortChildren(null, true);           
		    });
	       return false;
	   });
	 

	 //tree全部收合
	 $("#btnCollapseAll").click(function(){
	       $("#tree").dynatree("getRoot").visit(function(node){
	           node.expand(false);            
	       });	      
		   return false;
	   }); 
	 
	 
	 //tree 重新载入
	 $("#btnRefresh,#btnRefresh2").click(function(){		
		$("#tree").dynatree("getTree").reload();		
	 }); 
	 window.parent.mainAccFrame.location.href=$("#Menu_List a").eq(0).attr("href"); 
});

</script>

{str}
<div id="leftSide" class="side">

<!-- 搜寻条件 -->
<table width="95%" border="0" cellspacing="1" cellpadding="0" class="tblMy3D" >
  <thead>
  <caption class="title0 bgImg_0"  style="backgroud-repeat:repeat-x">
  {title} <span>
  <table class='show_mbrs'>
    <tr>
      <td>启用:</td>
      <td>{rs1} 人</td>
      <td>暂停:</td>
      <td>{rs2} 人</td>
    </tr>
    <tr>
      <td>停用:</td>
      <td>{rs0} 人</td>
      <td>合计:</td>
      <td>{rsAll} 人</td>
    </tr>
  </table>
  </span>
    </div>
  
  </caption>
  <tr class="bgClc_0"  >
    <td align="center" colspan="8" style="padding-top:5px;"><div style="padding-top:5px; {display}" id="divBtnOpen">
      <div id="leftTop">
        <form METHOD="POST" ACTION="#">
          帐号:
          <input type='text' id='account' name='account' size='12' value="{account}" >
          <input type='hidden' id='login_acct' name='login_acct' size='15' value="{login_acct}" >
          <input type='hidden' id='login_acl' name='login_acl' size='15' value="{login_acl}" >
          <input id='srh_tree' style="width: 40px; height: 25px" type='button' value='搜寻' >
        </form>
      </div>
      <div id="leftTop"> 模式:
        <select name='cmd' id='cmd'>
          <option value='list'>列表</option>
          <option value='tree'>树状</option>
          <option value='edit'>编辑</option>
          <option value='amount'>限额</option>
        </select>
        状态:
        <select name='enabled' id='enabled'>
          <option value='1'>启用</option>
          <option value='0'>停用</option>
        </select>
      </div></td>
  </tr>
    </thead>
  
  <tbody id="tbdLastBetList">
  </tbody>
  <tr class="title0 bgImg_0"> </tr>
</table>
{tree}
<!-- 显示资料 -->
<table width="95%" border="0" cellspacing="1" cellpadding="0" class="tblMy3D" id="Menu_Tree" style="display:none">
  <thead>
  <caption class="title0 bgImg_0"  style="backgroud-repeat:repeat-x">
  <div class="description"> <a href="#" id="btnExpandAll">展开</a> - <a href="#" id="btnCollapseAll">收合</a> <a href="#" id="btnRefresh2">更新</a>
    <input type="button" id="btnRefresh" name="btnRefresh" value='更新' style="visibility:hidden ">
  </div>
  </caption>
  <tr class="bgClc_0"  >
    <td colspan="8" style="padding-top:5px;"><div id='tree_body'></div></td>
  </tr>
    </thead>
  
</table>
</div>
